package org.example.springblogdemo.util;

import org.example.springblogdemo.pojo.dataobject.BlogInfo;
import org.example.springblogdemo.pojo.dataobject.UserInfo;
import org.example.springblogdemo.pojo.request.AddBlogRequest;
import org.example.springblogdemo.pojo.request.UpdateBlogRequest;
import org.example.springblogdemo.respone.BlogInfoResponse;
import org.example.springblogdemo.respone.UserInfoResponse;
import org.springframework.beans.BeanUtils;

public class BeanTransUtils {
    public static BlogInfoResponse trans(BlogInfo blogInfo){
        BlogInfoResponse response = new BlogInfoResponse();
        BeanUtils.copyProperties(blogInfo, response);
        return response;
    }


    public static UserInfoResponse transUser(UserInfo userInfo) {
        UserInfoResponse response = new UserInfoResponse();
        BeanUtils.copyProperties(userInfo, response);
        return response;
    }

    public static BlogInfo transBlogInfo(AddBlogRequest addBlogRequest) {
        BlogInfo response = new BlogInfo();
        BeanUtils.copyProperties(addBlogRequest, response);
        return response;
    }
    public static BlogInfo transBlogInfo(UpdateBlogRequest updateBlogRequest) {
        BlogInfo response = new BlogInfo();
        BeanUtils.copyProperties(updateBlogRequest, response);
        return response;
    }
}